From 348b66f3e1fa101f448c5a6f7f2f8bcc8d3a1b6f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 5 May 2008 23:38:31 +0000 Subject: [PATCH] Apply a patch by Marek Kasik to display more printer 2008-05-05 Matthias Clasen Apply a patch by Marek Kasik to display more printer status information in the print dialog. * modules/printbackends/cups/gtkprintbackendcups.c: Translate printer-state-reasons into suitable messages and icons. * gtk/stock-icons/16/gtk-print-error.{svg,png}: * gtk/stock-icons/16/gtk-print-report.{svg,png}: * gtk/stock-icons/16/gtk-print-warning.{svg,png}: * gtk/Makefile.am: * gtk/gtkstock.h: New stock icons to display printer state. svn path=/trunk/; revision=20076 --- docs/reference/ChangeLog | 5 + docs/reference/gtk/Makefile.am | 3 + docs/reference/gtk/tmpl/gtkstock.sgml | 27 + gtk/Makefile.am | 3 + gtk/gtkstock.h | 3 + gtk/stock-icons/16/gtk-print-error.png | Bin 0 -> 711 bytes gtk/stock-icons/16/gtk-print-error.svg | 584 ++++++ gtk/stock-icons/16/gtk-print-report.png | Bin 0 -> 724 bytes gtk/stock-icons/16/gtk-print-report.svg | 282 +++ gtk/stock-icons/16/gtk-print-warning.png | Bin 0 -> 685 bytes gtk/stock-icons/16/gtk-print-warning.svg | 505 ++++++ gtk/stock-icons/24/gtk-print-error.png | Bin 0 -> 1130 bytes gtk/stock-icons/24/gtk-print-error.svg | 716 ++++++++ gtk/stock-icons/24/gtk-print-report.png | Bin 0 -> 1154 bytes gtk/stock-icons/24/gtk-print-report.svg | 1410 +++++++++++++++ gtk/stock-icons/24/gtk-print-warning.png | Bin 0 -> 1099 bytes gtk/stock-icons/24/gtk-print-warning.svg | 1577 +++++++++++++++++ .../printbackends/cups/gtkprintbackendcups.c | 127 ++ 18 files changed, 5242 insertions(+) create mode 100644 gtk/stock-icons/16/gtk-print-error.png create mode 100644 gtk/stock-icons/16/gtk-print-error.svg create mode 100644 gtk/stock-icons/16/gtk-print-report.png create mode 100644 gtk/stock-icons/16/gtk-print-report.svg create mode 100644 gtk/stock-icons/16/gtk-print-warning.png create mode 100644 gtk/stock-icons/16/gtk-print-warning.svg create mode 100644 gtk/stock-icons/24/gtk-print-error.png create mode 100644 gtk/stock-icons/24/gtk-print-error.svg create mode 100644 gtk/stock-icons/24/gtk-print-report.png create mode 100644 gtk/stock-icons/24/gtk-print-report.svg create mode 100644 gtk/stock-icons/24/gtk-print-warning.png create mode 100644 gtk/stock-icons/24/gtk-print-warning.svg diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 037b48e6da..27739e20d9 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,8 @@ +2008-05-05 Matthias Clasen + + * docs/reference/gtk/Makefile.am: + * docs/reference/gtk/tmpl/gtkstock.sgml: Add new icons. + 2008-04-10 Cody Russell * docs/reference/gdk/tmpl/windows.sgml: Fix to say diff --git a/docs/reference/gtk/Makefile.am b/docs/reference/gtk/Makefile.am index fca0a7a639..ef4d54287a 100644 --- a/docs/reference/gtk/Makefile.am +++ b/docs/reference/gtk/Makefile.am @@ -238,7 +238,10 @@ HTML_IMAGES = \ $(top_srcdir)/gtk/stock-icons/24/gtk-paste.png \ $(top_srcdir)/gtk/stock-icons/24/gtk-preferences.png \ $(top_srcdir)/gtk/stock-icons/24/gtk-print.png \ + $(top_srcdir)/gtk/stock-icons/24/gtk-print-error.png \ $(top_srcdir)/gtk/stock-icons/24/gtk-print-preview.png \ + $(top_srcdir)/gtk/stock-icons/24/gtk-print-report.png \ + $(top_srcdir)/gtk/stock-icons/24/gtk-print-warning.png \ $(top_srcdir)/gtk/stock-icons/24/gtk-properties.png \ $(top_srcdir)/gtk/stock-icons/24/gtk-quit.png \ $(top_srcdir)/gtk/stock-icons/24/gtk-redo-ltr.png \ diff --git a/docs/reference/gtk/tmpl/gtkstock.sgml b/docs/reference/gtk/tmpl/gtkstock.sgml index e4ac541a2d..6a676889aa 100644 --- a/docs/reference/gtk/tmpl/gtkstock.sgml +++ b/docs/reference/gtk/tmpl/gtkstock.sgml @@ -742,6 +742,15 @@ The "Print" item. + + + + +The "Print Error" item. + + + +@Since: 2.14 @@ -752,6 +761,24 @@ The "Print Preview" item. + + +The "Print Report" item. + + + +@Since: 2.14 + + + + +The "Print Warning" item. + + + +@Since: 2.14 + + The "Properties" item. diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 539a54c0fb..1ed841cdc3 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -1006,7 +1006,10 @@ STOCK_ICONS = \ stock-icons/16/gtk-paste.png \ stock-icons/16/gtk-preferences.png \ stock-icons/16/gtk-print.png \ + stock-icons/16/gtk-print-error.png \ stock-icons/16/gtk-print-preview.png \ + stock-icons/16/gtk-print-report.png \ + stock-icons/16/gtk-print-warning.png \ stock-icons/16/gtk-properties.png \ stock-icons/16/gtk-quit.png \ stock-icons/16/gtk-redo-ltr.png \ diff --git a/gtk/gtkstock.h b/gtk/gtkstock.h index 52571477ed..5a7408b5cd 100644 --- a/gtk/gtkstock.h +++ b/gtk/gtkstock.h @@ -143,7 +143,10 @@ void gtk_stock_set_translate_func (const gchar *domain, #define GTK_STOCK_PASTE "gtk-paste" #define GTK_STOCK_PREFERENCES "gtk-preferences" #define GTK_STOCK_PRINT "gtk-print" +#define GTK_STOCK_PRINT_ERROR "gtk-print-error" #define GTK_STOCK_PRINT_PREVIEW "gtk-print-preview" +#define GTK_STOCK_PRINT_REPORT "gtk-print-report" +#define GTK_STOCK_PRINT_WARNING "gtk-print-warning" #define GTK_STOCK_PROPERTIES "gtk-properties" #define GTK_STOCK_QUIT "gtk-quit" #define GTK_STOCK_REDO "gtk-redo" diff --git a/gtk/stock-icons/16/gtk-print-error.png b/gtk/stock-icons/16/gtk-print-error.png new file mode 100644 index 0000000000000000000000000000000000000000..934ee68d3bc366782b6f8723afe921fe61f631cf GIT binary patch literal 711 zcmV;&0yzDNP)k!uZtt=V!j=wx=VgSyE3 zDvK^r(Z6e8m?8+(A?PM`DmrF#h!8vk7N$oJLRj-3Wo6p@J4f4Z`^~q*a=2#F7hYc8 z2j0*3dB4vqwAO5@yQlM>Wm$LFL55-6@9DnVStw|&3#+56U8mA1{V!#$tnTP)*IVz{ z{&ujJ*_r=2hf)fqY}o$nN-6ARj*^Z_001MyBS@)GQX-W?N{N(;)>Ezj2WV<;E^^-N zWIJsO7#@0G>r?|Hbl9@Q3%rScB99~s~4;HzO`ku+2%;(BsGB`wTJ79+(%yx;I6E~5e_2_18K`g z<}giy3kyumeyz6w2q}0oI8c)C`ny4nxLnwKdyDEuGKsUPi9M@p#Z!3t~RoN+D!^8d__90n3%HV!)-#7mJ*%*d)`pyEx$WQf66@%_8h}Or@BL$N6%+ zJ`c!QIsCpr$rJDen4kU5(4)s3^z6r3Q9&{uXZpt+`)*ukb@nsj{Drm$z%2y2l#rKe tX<2wDr$p7t8u8t`_!jW%l*a?`@HhSL?O=6OkC^}f002ovPDHLkV1oZ`Lk9o= literal 0 HcmV?d00001 diff --git a/gtk/stock-icons/16/gtk-print-error.svg b/gtk/stock-icons/16/gtk-print-error.svg new file mode 100644 index 0000000000..962d42ba30 --- /dev/null +++ b/gtk/stock-icons/16/gtk-print-error.svg @@ -0,0 +1,584 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gtk/stock-icons/16/gtk-print-report.png b/gtk/stock-icons/16/gtk-print-report.png new file mode 100644 index 0000000000000000000000000000000000000000..8e2ab74872d026b1c24fac8ad90c8116867f1501 GIT binary patch literal 724 zcmV;_0xSKAP)D#U?{?p}Eb9(CNGbK;ZtuPB)PdtTsnylf>BQIK&c9?@rqk8a>1^$B z{q3M<>C7+ABBex17p{$6N{ODeJ0npB0AO@v6d@#12!xafArL~+*4p-efRimPY0jHT zw$rwNk$3OYoTZRxnugEk+ZkXO3ButpjZIAmAyUqoCIASB!x%;)6L9{**-|Ox7k9Rs z$;n9)2?HV5XP{|}@*)jSih z=pSCCw#v(ak{nu(dT_gS=Jyve_Q@&I?d4&YX__rQ-zh39s;RAMNOSKS7$-O1k6Tw% zd2&!vP_#!UX4n)J7ZQn;9CHC^LgV$DR~Zu?{}v@n--~G{3B@c9A1vVG&j5y%#HAFb zt04Uq`X4{Vw(V3MbRWW9)<`67u^ce~SPZQZj3$VzuA%H;I^gQHD`^R40v1o+1}G@V zBc50X2cij + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/gtk/stock-icons/16/gtk-print-warning.png b/gtk/stock-icons/16/gtk-print-warning.png new file mode 100644 index 0000000000000000000000000000000000000000..52410c38df01def18454d549c5a329dfe97e3686 GIT binary patch literal 685 zcmV;e0#f~nP)`IsPHbvMvtvpYP2-7-RCQr?1=0{hBjNDdS{JPhYoL zSmXKI!CUMlHWNiDg;E|oe|Du5-r{Ahj$8nM@$fiODwLE+rI1o0rJ`kj%l`oy8XF6o zbDb=vMFHWlrv=VRDufU;H#h$qkV>UVCX?){twl}VEp+r;)w)p?SZ(~di$N*ccY>;V3%5!HDTNKmZ6~`wQw$S zGRE-bYm{1_VB(XYv#V1FgTbjxCbQFHS=Ml!-|wrbu2vnVPLj=LU4SQ}V{G)sxqLv- zamz3h|E~Ogzb_mP57Qd3&4;OXOAgPE*;%uvVXuh{)|sRAYt7_UziHanWG3IdHmw2M zcmRYHJbD~jG^PjlLo{y9QngC(;(d~B>m)lW)7%>wai?&7@FrU8{M~Uh(dlV|r;7kM zYgYl#RS!pQgjln>tPpVg#IXYRQ0O7MD-x717XW+n6A$HKMIOa0xhrz?GlYnpi9@9qmp=NlAIx$}7JCmMRXm T|LjwJ00000NkvXXu0mjf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gtk/stock-icons/24/gtk-print-error.png b/gtk/stock-icons/24/gtk-print-error.png new file mode 100644 index 0000000000000000000000000000000000000000..28517473d1abfa61d11ad21a89c8b6c0f2db4278 GIT binary patch literal 1130 zcmV-w1eN=VP)3;XCT_ac1Tk$)7Y$7l-Ly5dHO5_QTvVt@HBrFCq6~2~4q6!m2L_nA zbMNV5hR2kF8cqM?=A3iSx##=eSBx?IpJHWu`PHf3V~&$NYK+Oc|8EhIr0w^eIP&S| zU#!_Q#;kdIdXGB`3-jh##c>?d(|g>>c2`ynjWJeEPA(4~-bX2gQVOkfdal>3bNo51 zXYGbAP)hN~;1!ezq7+J0#$1%5wWVc4_iYH!O4HD=XO-3~7AU2c*Ut@5N-;1nnATh& zN>X#Bko4Hv+WH~@O;clI7Oht-5s~KyXr;LP`#@TAjZ(6#xl#&%mKTYEQktgbrpye| zsSJ8n$pCbAw%2Oge|1}JEzxL{*nBLdxt5Id1X!4uVCMRD=7T}y!c9f?G;nk(@*6<>Z$ zrQgq+6%|;vjY7O);c5DJ`r|q-OBZFSoYk#x8u@lubu(kwE!05i(R{S?Pfd}MCqjf zW_DTU@5em8aDlzG+YmrR5Rv8c#u!9|H%dzh507ZGrKD>a0N@$J{d=Kxv%&rIDg}W6 zR!Irg{{71>gS3m3F^K13oj*@eK>?elXMj~%q?DkQFnas1tboFiA<9G{Wo7sdA6{3H z#NZ$S5dzWKOn}xJ%eDdd#FURBA)7>wuPhC$C4yqTY&Av zlc!IfJn`{={hzhC?2Sy4a2)C?E74kmF(88DdE5+zxEp=SC0r9<@J<7^00E%p;5!|^ zH8nSsR99DR2yy1-m_79kT)RdfFP}o&W+onIE*2wNx1Dfv1GmP;$A0b=015O37UX>cg0000007*qoM6N<$f{mCFyZ`_I literal 0 HcmV?d00001 diff --git a/gtk/stock-icons/24/gtk-print-error.svg b/gtk/stock-icons/24/gtk-print-error.svg new file mode 100644 index 0000000000..0ad756bf4f --- /dev/null +++ b/gtk/stock-icons/24/gtk-print-error.svg @@ -0,0 +1,716 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gtk/stock-icons/24/gtk-print-report.png b/gtk/stock-icons/24/gtk-print-report.png new file mode 100644 index 0000000000000000000000000000000000000000..13304368e01792a5a4291f5d098c988e7fe85ef1 GIT binary patch literal 1154 zcmV-|1bzF7P)*L=Yuab0tFm)~!ok-;w}B3^s3m@n5R%WgucKtRER5BAh;brlMR> zqRMj-RAub%?|&SCL0@lg4b}HDQA#~Jz!2fo$Jz-V$ipxui8OI z*+CB*Re+s4w{;s<;{5vVZu0p&#Zs}X+)!2a1jx)eT)dX!`b>$A=6dFe5rePo%*CPK zbM)vp6L-&4cU#54z`%;S`o!3-UGKJk{>2gX#_Mn5`R=_dsf=C_^X1uF{5+YbFTDWQHk;Nz!S8?Puq}fpyH_(lIj!R43mcs26NiCUO#s((2RA*p ziA$4{h;g@o)m=6>A8>N)79Cxkn1*1RLPNq}MT1RKgGCg_xTet7zLEb$qVs<7(dczW#X%JHNY?oOv?h`owtS-0nYw$o8j*- zVVi>EN0_3RnkfQMa6({0PwzrY@8LN-6d7j_nwxfn}EgpMEyH2;hbWce1N# zX=}j?H3cW2;Di-GK(6TH`VmnaGhcF973WY&DHE`iQehB;X4|TE+FokEZyn}OOfxxi zhvwFmcwtOeYYKp_)&_pLoW(YUx!Ei|>(Wf0_d>uj0W0vrLkAA*d;3A}bBw`Ex}PWt zY42FY=y-%j330hR(9fOR`w893IrWpi^^*P10EeyI8G zHTj()WRm^3LHKDcsaYTu7P{IvUc95pXV zs6>k-ap#(tS7|I=pe4#OlX00fOV07*qoM6N<$f|Dj7h5!Hn literal 0 HcmV?d00001 diff --git a/gtk/stock-icons/24/gtk-print-report.svg b/gtk/stock-icons/24/gtk-print-report.svg new file mode 100644 index 0000000000..8d0e4289f0 --- /dev/null +++ b/gtk/stock-icons/24/gtk-print-report.svg @@ -0,0 +1,1410 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gtk/stock-icons/24/gtk-print-warning.png b/gtk/stock-icons/24/gtk-print-warning.png new file mode 100644 index 0000000000000000000000000000000000000000..dd70e0be92b5880446b55937bedfb606293e69d4 GIT binary patch literal 1099 zcmV-R1ho5!P)B>vK_~t}r<+Q}Ll zYT^e7e`F>Gk&#T@MwTpDw#3B5nTxV+Sj#8E_p5*1-bMJlUcg}g|p7(@OivLqg$tK@D*7}xVg!d_>lCEDXLWr<# zF&}ApeeZ!Ki%O{_*WuPfMj$Y&u2&4hP={L&8OdxV^-w8gvRcy^pS*~a5-BB`)E36t z65VRCvRt$&Qy`_p-Fq4-1VT!rkO^ZUB^Bl6Dbtq{ph=CAl5JOc9gjdtEvDZvKuU?r z)w|%iL`V@GONm&xS5#Eo3_!zCTAIY`cqBrI8wY4o^3y5Tg6A4iikRn8N&w1l<{e0> z;V5$?R*)90pzDvf?k*_6=kwv8^+!F|L_&Ekif4M7_l~_o?#4U0|LR9oAJ6LW#k=B}=;zhi*r=4L$*oIPDtS^1!6dP?_rJS&DiFgQ$l zV1)N;G=gDx?t?I;WlyvDf%}c_6DNL6v!p-nbUF){L!MK!qU<*JsdU&g@P%K zU%4{F%S}zRZ;wV~F~P19LHF<=ExY&Ve~ynA_V@K22ez94=7Mwe#r9&(kBlI-#T;ML zWv@~@zv{$smm)t)@S1akEqAP6-vSmd9LI_b^TZLxQ(9Kc6$DcZr0^Dvl4fY5bmN;Oe&BB_D_;D)Ck!;D0 z@cU&SLI`03bRk68Fv6w{**R=@HYcg^iOIkCp{Ix1M-or5d%%a;BzdxMO>A!0HbwO( zUMv=?*#ziDFx-Ch=#i#W-{%>BfUNW|CQVP6|Ged%C3|z$3g+jPTDN|ErT|s}n`&RE z`O#5UV$09ZOA7FMeK^}bLKh)&*Dl{dl~VjM6;|Gv;ONlMg{=a}0P^g`_Gj|*Zr?W_ znYS(Xuz$vne>OlQ^`D4$;?m@I=g*z%0NesF16e>OpaZEJ{K}#L1NaB<{0Bjdj#|K* Rwfg`7002ovPDHLkV1ivb2uJ_` literal 0 HcmV?d00001 diff --git a/gtk/stock-icons/24/gtk-print-warning.svg b/gtk/stock-icons/24/gtk-print-warning.svg new file mode 100644 index 0000000000..876486bc75 --- /dev/null +++ b/gtk/stock-icons/24/gtk-print-warning.svg @@ -0,0 +1,1577 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c index 3c5e1844a2..7277e42b21 100644 --- a/modules/printbackends/cups/gtkprintbackendcups.c +++ b/modules/printbackends/cups/gtkprintbackendcups.c @@ -1016,6 +1016,45 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend, gint job_count = 0; gboolean status_changed = FALSE; GList *node; + gint i,j; + const gchar *reason_msg = NULL; + gchar *reason_msg_desc = NULL; + gchar *tmp_msg = NULL; + gint printer_state_reason_level = 0; /* 0 - none, 1 - report, 2 - warning, 3 - error */ + gboolean interested_in = FALSE; + gboolean found = FALSE; + static const char * const reasons[] = /* Reasons we're interested in */ + { + "toner-low", + "toner-empty", + "developer-low", + "developer-empty", + "marker-supply-low", + "marker-supply-empty", + "cover-open", + "door-open", + "media-low", + "media-empty", + "offline", + "connecting-to-device", + "other" + }; + static const char * reasons_descs[] = + { + N_("Printer '%s' is low on toner."), + N_("Printer '%s' has no toner left."), + N_("Printer '%s' is low on developer."), + N_("Printer '%s' is out of developer."), + N_("Printer '%s' is low on at least one marker supply."), + N_("Printer '%s' is out of at least one marker supply."), + N_("The cover is open on printer '%s'."), + N_("The door is open on printer '%s'."), + N_("Printer '%s' is low on paper."), + N_("Printer '%s' is out of paper."), + N_("Printer '%s' is currently off-line."), + N_("Printer '%s' may not be connected."), + N_("There is a problem on printer '%s'.") + }; /* Skip leading attributes until we hit a printer... */ @@ -1042,6 +1081,49 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend, description = attr->values[0].string.text; else if (strcmp (attr->name, "printer-state-message") == 0) state_msg = attr->values[0].string.text; + else if (strcmp (attr->name, "printer-state-reasons") == 0) + /* Store most important reason to reason_msg and set + its importance at printer_state_reason_level */ + { + for (i = 0; i < attr->num_values; i++) + { + if (strcmp (attr->values[i].string.text, "none") != 0) + { + interested_in = FALSE; + for (j = 0; j < G_N_ELEMENTS (reasons); j++) + if (strncmp (attr->values[i].string.text, reasons[j], strlen (reasons[j])) == 0) + { + interested_in = TRUE; + break; + } + + if (interested_in) + { + if (g_str_has_suffix (attr->values[i].string.text, "-report")) + { + if (printer_state_reason_level <= 1) + { + reason_msg = attr->values[i].string.text; + printer_state_reason_level = 1; + } + } + else if (g_str_has_suffix (attr->values[i].string.text, "-warning")) + { + if (printer_state_reason_level <= 2) + { + reason_msg = attr->values[i].string.text; + printer_state_reason_level = 2; + } + } + else /* It is error in the case of no suffix. */ + { + reason_msg = attr->values[i].string.text; + printer_state_reason_level = 3; + } + } + } + } + } else if (strcmp (attr->name, "printer-state") == 0) state = attr->values[0].integer; else if (strcmp (attr->name, "queued-job-count") == 0) @@ -1167,8 +1249,52 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend, status_changed = gtk_printer_set_job_count (printer, job_count); status_changed |= gtk_printer_set_location (printer, location); status_changed |= gtk_printer_set_description (printer, description); + + /* Set description of the reason and combine it with printer-state-message. */ + if ( (reason_msg != NULL)) + { + for (i = 0; i < G_N_ELEMENTS (reasons); i++) + { + if (strncmp (reason_msg, reasons[i], strlen (reasons[i])) == 0) + { + reason_msg_desc = g_strdup_printf (reasons_descs[i], printer_name); + found = TRUE; + break; + } + } + + if (!found) + printer_state_reason_level = 0; + + if (printer_state_reason_level >= 2) + { + if (strlen (state_msg) == 0) + state_msg = reason_msg_desc; + else + { + tmp_msg = g_strjoin (" ; ", state_msg, reason_msg_desc, NULL); + state_msg = tmp_msg; + } + } + } + status_changed |= gtk_printer_set_state_message (printer, state_msg); + if (tmp_msg != NULL) + g_free (tmp_msg); + + if (reason_msg_desc != NULL) + g_free (reason_msg_desc); + + /* Set printer icon according to importance + (none, report, warning, error - report is omitted). */ + if (printer_state_reason_level == 3) + gtk_printer_set_icon_name (printer, "gtk-print-error"); + else if (printer_state_reason_level == 2) + gtk_printer_set_icon_name (printer, "gtk-print-warning"); + else + gtk_printer_set_icon_name (printer, "gtk-print"); + if (status_changed) g_signal_emit_by_name (GTK_PRINT_BACKEND (backend), "printer-status-changed", printer); @@ -1210,6 +1336,7 @@ cups_request_printer_list (GtkPrintBackendCups *cups_backend) "printer-location", "printer-info", "printer-state-message", + "printer-state-reasons", "printer-state", "queued-job-count" }; -- 2.30.2